﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Search.Master" Inherits="System.Web.Mvc.ViewPage<PagedList<App.Models.vi_ServiceDetail>>" %>
<%@ Import Namespace="Webdiyer.WebControls.Mvc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link rel="stylesheet" type="text/css" href="../../css/jquery.ui.all.css " />   
    <script language="javascript" type="text/javascript" src="../../js/jquery.ui.core.js" ></script>    
    <script language="javascript" type="text/javascript" src="../../js/jquery.ui.widget.js" ></script>
    <script language="javascript" type="text/javascript" src="../../js/jquery.ui.datepicker.js" ></script>    
    <script language="javascript" type="text/javascript" src="../../js/jquery.ui.datepicker-zh-CN.js" ></script>    
    <script type="text/javascript">
        //"删除"按钮的click事件处理程序
       function Pay() {
            var idList = [];
            $("[name='chkPayStatus']").each(function () {
                if ($(this).attr("checked") &&  !$(this).attr("disabled")) {
                    idList.push($(this).attr("value"));
                }
            });
            if (idList.length < 1) {
                alert("请至少选择一项未收费的项目进行收费");
                return;
            }            
            $.ajax({
                type: "POST",
                url: "Pay",
                data: "idList=" + idList,
                dataType: "text/plain",
                success: function (response) {
                    if (response == "success") {
                        window.location.reload();
                    } else {
                        alert(response);         //显示出错信息
                    }
                }
            });
        }
        function PrintReport(t) {
            var tm = $("#txtdate").attr("value");
            window.location.href = "/CheckoutService/PrintFeeReport?tm=" + tm + "&t=" + t;
            if (t == 1) {           //年报
                
            } else if (t == 2) {     //月报

            } else {                 //日报
            
            }
        }
        var totals = 0;
        $(document).ready(function () {
            //查询提交            
            $('#txtdate').datepicker({
                changeMonth: true,
                changeYear: true,
                dateFormat: 'yy-mm-dd'
            });
            $('#btnPay').click(Pay);        //注册"收费"按钮的click事件
            $("#chkAll").change(function () {
                totals = 0;
                if ($(this).attr("checked")) {
                    $("[name='chkPayStatus']").each(function () {
                        if (!$(this).attr("checked") && !$(this).attr("disabled")) {
                            $(this).attr("checked", "chekced");
                            var subtotals = parseFloat($(this).attr("subtotals"));
                            totals = totals + subtotals;
                        }
                    });
                } else {
                    $("[name='chkPayStatus']").each(function () {
                        if ($(this).attr("checked") && !$(this).attr("disabled")) {
                            $(this).removeAttr("checked");
                        }
                    });
                }
                $("#PayTotals").val(totals.toFixed(2));
            });
            $("[name='chkPayStatus']").change(function () {
                var subtotals = parseFloat($(this).attr("subtotals"));
                if ($(this).attr("checked")) totals = totals + subtotals;
                else
                    totals = totals - subtotals;
                $("#PayTotals").val(totals.toFixed(2));
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContentHead" runat="server">
    服务收费
</asp:Content>
<asp:Content ID="SearchCondition" ContentPlaceHolderID="SearchCondition" runat="server">
    <form method="post" action="/CheckoutService/List">
    逝者编号：<input id="DeadNO" name="DeadNO" style="width:120px" type="text" />&nbsp;&nbsp;
    逝者名称：<input id="DeadName" name="DeadName" style="width:80px" type="text" />
    <input id="btnQuery" type="submit" value="查找" />
    </form>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContentList" runat="server">  
   <div class="page">
   应收费<input type="text" style="color:Blue; width:60px;" value = "0.00" id="PayTotals" name="PayTotals" />
   <input id="btnPay" type="button" value="收费" class="btnsave btn" /> ==>
   <%: Html.ActionLink("打印费用明细单", "PrintDeadFeeList", new { DeadNO = (Model.Count > 0 ? Model.ElementAt(1).DeadNO : "") }, new { @class = "listlink" })%>
   <span style="float:right"><input type="text" id="txtdate" style="width:80px" readonly="readonly" name="txtdate" /> 
        <input type="button" name="btnReport" onclick="PrintReport(1)" value="年报" /> 
        <input type="button" name="btnReport" onclick="PrintReport(2)" value="月报" /> 
        <input type="button" name="btnReport" onclick="PrintReport(3)" value="日报" /> 
    </span>
   </div>    
   <%Html.RenderPartial("UcList", Model);%>       
</asp:Content>
